﻿#include <pagmo/problem.hpp>
#include <pagmo/algorithms/de.hpp>
#include <pagmo/population.hpp>
#include <iostream>

using namespace pagmo;

// 最简单的测试
struct SimpleProblem {
    vector_double fitness(const vector_double& x) const  {
        std::cout << "Fitness called: " << x[0] << ", " << x[1] << std::endl;
        return { x[0] * x[0] + x[1] * x[1] }; // 最小化 x² + y²
    }

    std::pair<vector_double, vector_double> get_bounds() const  {
        return { {-5, -5}, {5, 5} };
    }
};

int sp() {
    SimpleProblem prob;
    algorithm algo{ de(10) };
    population pop{ prob, 5 };

    std::cout << "Testing..." << std::endl;
    pop = algo.evolve(pop);
    std::cout << "Best: " << pop.champion_f()[0] << std::endl;

    return 0;
}